<%--
  Created by IntelliJ IDEA.
  User: lt
  Date: 2018/6/4
  Time: 19:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<jsp:useBean id="today" class="java.util.GregorianCalendar" />
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="id" value="${pageContext.request.getParameter('id')}"></c:set>

<title>卷烟订购表</title>

<link rel="stylesheet" href="${contextPath}/static/ace/components/_mod/jquery-ui/jquery-ui.css"/>
<link rel="stylesheet"
      href="${contextPath}/static/ace/components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css"/>
<link rel="stylesheet" href="${contextPath}/static/ace/components/_mod/jqgrid/ui.jqgrid.css"/>
<link href="${contextPath}/static/ztree/css/zTreeStyle.css" rel="stylesheet" />
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.min.js"></script>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.mockjax.js"></script>
<!-- 商品列表详情 -->
<script type="text/javascript" src="${contextPath}/static/franchisee/alertProdInfo.js"></script>
<script src="${contextPath}/static/statistics/js/vue.js"></script>
<script src="${contextPath}/static/countjs/regularYz.js"></script>
<script src="${contextPath}/static/time/datetime.js"></script>
<script src="${contextPath}/static/jqgridtoExcel.js"></script>
<%--<jsp:include page="../../head.jsp"/>--%>
<style type="text/css">
	body {
			overflow:-Scroll;
			overflow-x:hidden;
	}
    .customBtn {
        line-height: 20px;
        margin-bottom: 3px;
    }

    .btnLine {
        margin-left: 1px;
        margin-top: 8px;
        margin-bottom: 2px;
    }

    @-webkit-keyframes bouncedelay {
        0%, 80%, 100% {
            -webkit-transform: scale(0.0)
        }
        40% {
            -webkit-transform: scale(1.0)
        }
    }

    @keyframes bouncedelay {
        0%, 80%, 100% {
            transform: scale(0.0);
            -webkit-transform: scale(0.0);
        }
        40% {
            transform: scale(1.0);
            -webkit-transform: scale(1.0);
        }
    }

    .autocomplete-suggestions {
        border: 1px solid #999;
        background: #FFF;
        overflow: auto;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestions strong {
        font-weight: normal;
        color: #3399FF;
    }

    @-moz-document url-prefix() {
        fieldset {
            display: table-cell;
        }
    }

    .ui-jqgrid .ui-priority-secondary{
        background: #d5effc;
    }

    .ui-jqgrid .ui-jqgrid-title{font-size:12px;}    /*修改grid标题的字体大小*/

    .ui-jqgrid-sortable {font-size:12px;}   /*修改列名的字体大小*/

    .ui-jqgrid tr.jqgrow td {font-size:12px; font-family:"宋体"} /*修改表格内容字体*/

    .ui-jqgrid-sortable {
        text-align: center;
    }

    .ui-jqgrid-sortable input{
        text-align: right;
    }

    .SelectBG{
        background-color:red;
    }
</style>

<div class="row" id="app">
    <div class="row btnLine">
        <div class="button-len col-sm-12">
            <div style="width: 100%; margin-bottom: 10px;">
				<shiro:hasPermission name="SHORT:SHOP:ADD">
                    <button class="btn btn-white btn-info btn-sm customBtn" id="mendian">
                        <i class="ace-icon fa fa-pencil blue"></i> 门店审批
                    </button>
                </shiro:hasPermission>
                <shiro:hasPermission name="SHORT:ZONE:ADD">
                    <button class="btn btn-white btn-info btn-sm customBtn" id="approval">
                        <i class="ace-icon fa fa-pencil blue"></i> 区域审批
                    </button>
                </shiro:hasPermission>
                <button class="btn btn-white btn-info btn-sm customBtn" onclick="daochu();">
                    <i class="ace-icon fa fa-pencil blue"></i> 导出Excel表格
                </button>
                <button class="btn btn-white btn-info btn-sm customBtn" onclick="compute();">
                    <i class="ace-icon fa fa-pencil blue"></i> 计算
                </button>
                <label style="">选择店铺：</label>
                <select class="input-sm" id="shopId">
                    <option :value="obj.shopId" v-for="(obj, index) in arrayShop">{{ obj.shopName }}</option>
                </select>
                <div style="width: 100%; margin-bottom: 10px;">
			                年份 :
	                <select class="input-sm" id="yearId" onchange="getWeeks(this)" >
	                    <c:forEach begin="${today.get(1)}" end="2020" var="i" step="1">
	                        <option value="<c:out value='${i}'/>"><c:out value='${i}'/>年</option>
	                    </c:forEach>
	                </select>
			                周次：
	                <select class="input-sm" id="dateSearch" onchange="dateRange(this)">
	                    <c:forEach begin="${today.get(3)}" end="52" var="i" step="1">
	                        <option value="<c:out value='${i}'/>">第<c:out value='${i}'/>周</option>
	                    </c:forEach>
	                </select>
			                时间段：<input id ="_dateRange_import" readonly="readonly" type="text" />
			    </div>
                <button class="btn btn-sm btn-white btn-info search-len customBtn"
                        onclick="searchOrder()">
                    <i class="ace-icon fa fa-search orange"></i>查询
                </button>
            </div>
        </div>
    </div>
<form action="${contextPath}/ktcount/exportTobaccoExcels" method="post" id="exportExcel" style="display:none">
    <input type="hidden" id="exportExcelData-shopName" name="shopName">
    <input type="hidden" id="exportExcelData-shoptype" name="shopType">
    <input type="hidden" id="exportExcelData-shopId" name="shopId">
    <input type="hidden" name="tableType" value="stock">
</form>
    <!-- 内容数据开始 -->
    <div id="god" class="col-xs-12">
        <table id="grid-table"></table>
        <div id="grid-pager"></div>
    </div>
    <!-- 内容数据结束 -->
</div>

<!-- 通用变量 -->
<script type="text/javascript">
    var lastsel;
    var SelectRowIndx;
    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";

    var grid_prod_selector = "#grid-prod-table";
    var pager_prod_selector = "#grid-prod-pager";

    var laypage = layui.laypage,
        layer = layui.layer
    laydate = layui.laydate;
    //请求数据集
    var queryModel = {
        //分页参数
        page: '1',
        rows: '10',
        parentId: '',
        commodityIds: [],
    }

    //jqGrid 页面加载完带参数请求
    var filters = {
        "rules": [
            {
                "field": "state",
                "data": '1'
            }
        ]
    };
    var grid_data = {'filters': JSON.stringify(filters)};
    /* 导出Excel */ 
    function daochu(){   
	  exportExcel.jqgridtoExcel($("#gview_grid-table"),$("#grid-table"),'卷烟订购表');
    }
</script>

<!-- Vue实现类 -->
<script type="text/javascript">

    var app = new Vue({
        el: '#app',
        data: {
            objcte: [],
            priceTypeArray: [],
            parentArray: [],
            arrayShop: [],
            yanType1: [],
            yanType2: [],
            yanType3: [],
            yanType4: [],
            yanType5: [],
        },
        methods: {

        }
    })
    
    var getShop = function () {
        var filters = {
            "rules": [
                {
                    "field": "type",
                    "data": 'kt'
                },
                {
                    "field" : "state",
                    "data": '5'
                }
            ]
        };
        queryModel.shopType = "'加盟', '直营'";
        queryModel.filters = JSON.stringify(filters);
        queryModel.state = '5';
        $.ajax({
            url: '${contextPath}/ktCommon/getShopList2User',
            type: 'post',
            data: queryModel,
            success: function (data) {
                var dataArray = data;
                app.arrayShop = dataArray;
               // get(dataArray[0].shopId)
            },
            error: function (error){
            	get();
                layer.msg("获取出错："+data.message)
            }
        })
    }
    getShop();
</script>

<!-- 事件实现 -->
<script type="text/javascript">

    //新增商品
    $("#addProduct").click(function () {
        prodInfo('${contextPath}', grid_prod_selector, pager_prod_selector);
        $('#myModal').modal('show');
    })

    $("#approval").click(function () {
        approval()
    });
    
    $("#mendian").click(function () {
        mendian()
    });

    $("#confirm").click(function () {
        confirm()
    });

    $("#appProd").click(function () {
        addRowData();
    })
    //
    $("#xia").click(function () {
        $("#detail").css('background-color','#f5f5f5');
        $("#basics").css('background-color','#FFFFFF');
        $("#detail").css('border-radius','12px 0px 12px 0px');
        $("#basics").css('border-radius', '0px');
        $("#table1").addClass("hide");
        $("#table3").removeClass("hide");
        $("#xia").addClass("hide");
        $("#shang").removeClass("hide");
    });

    $("#shang").click(function () {
        $("#basics").css('background-color','#f5f5f5');
        $("#detail").css('background-color','#FFFFFF');
        $("#basics").css('border-radius','12px 0px 12px 0px');
        $("#detail").css('border-radius', '0px');
        $("#table3").addClass("hide");
        $("#table1").removeClass("hide");
        $("#shang").addClass("hide");
        $("#xia").removeClass("hide");
    });

    $("#basics").click(function () {
        $("#detail").css('background-color','#f5f5f5');
        $("#basics").css('background-color','#FFFFFF');
        $("#basics").css('border-radius','12px 0px 12px 0px');
        $("#detail").css('border-radius', '0px');
        $("#table3").addClass("hide");
        $("#table1").removeClass("hide");
        $("#xia").addClass("hide");
        $("#shang").removeClass("hide");
    });

    $("#detail").click(function () {
        $("#detail").css('background-color','#FFFFFF');
        $("#basics").css('background-color','#f5f5f5');
        $("#detail").css('border-radius','12px 0px 12px 0px');
        $("#basics").css('border-radius', '0px');
        $("#table1").addClass("hide");
        $("#table3").removeClass("hide");
        $("#shang").removeClass("hide");
        $("#xia").addClass("hide");
    });

    /************* 时间事件 **************/
    //开始时间
    $('#beginTime').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: 2,
        showMeridian: 1,
        format: "yyyy-mm-dd",
//        startDate:new Date(),
    });

    //结束时间
    $('#endTime').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: 2,
        showMeridian: 1,
        format: "yyyy-mm-dd",
//        startDate:new Date(),
    });

</script>

<!-- 调用方法 -->
<script type="text/javascript">
/* 区域审批功能 */
    var approval = function () {
    	var ids = $(grid_selector).jqGrid('getGridParam', 'selarrrow');
        var len = ids.length;
        if(len == 0){
            layer.msg("提示：请选择需要审批的订单");
            return
        }
        /* 获取表格输入框中的值  */
        var rowId = $(grid_selector).jqGrid("getGridParam", "selarrrow");
        for(var x = 0; x < rowId.length; x++){
        	var specialBrandQuantity = rowId[x] + "_specialBrandQuantity"; 
        	var zoneCheckQuantity = rowId[x] + "_zoneCheckQuantity"; 
        	var confirmQuantity = rowId[x] + "_confirmQuantity"; 
        	var actualQuantity = rowId[x] + "_actualQuantity"; 
        	var remark = rowId[x] + "_remark";
        	var shopRecommendUnitQuantity = rowId[x] + "_shopRecommendUnitQuantity";
        	
            var specialBrandQuantity= $('#'+specialBrandQuantity).val(); 
            var zoneCheckQuantity= $('#'+zoneCheckQuantity).val(); 
            var confirmQuantity= $('#'+confirmQuantity).val(); 
            var actualQuantity= $('#'+actualQuantity).val(); 
            var remark= $('#'+remark).val(); 
            var shopRecommendUnitQuantity= $('#'+shopRecommendUnitQuantity).val(); 
         　		$(grid_selector).jqGrid('setRowData',rowId[x],{
         　			specialBrandQuantity:specialBrandQuantity,
         　			zoneCheckQuantity:zoneCheckQuantity,
          			confirmQuantity:confirmQuantity,
          			actualQuantity:actualQuantity,
          			remark:remark,
          			shopRecommendUnitQuantity:shopRecommendUnitQuantity
          			},''); 
        }
            
        /* 获取表格所有数据  */
        var selectedIds = $(grid_selector).jqGrid("getGridParam", "selarrrow");
        var allData = $(grid_selector).getRowData();
        var shopId = $("#shopId").val();
        for(var i = 0; i< allData.length; i++){
        	allData[i].batchNo = '';
        	allData[i].shopId = shopId;
			for(var x = 0; x <= i; x++){		 
				 allData[i].id = selectedIds[x]; 
        	}
			if(allData[i].seasonType == '平常'){
				allData[i].seasonType = '1'
			}
			if(allData[i].seasonType == '旺季'){
				allData[i].seasonType = '2'
			}
			if(allData[i].seasonType == '中秋'){
				allData[i].seasonType = '3'
			}
			if(allData[i].seasonType == '春节'){
				allData[i].seasonType = '4'
			}
			if (allData[i].productStatus == '正常'){
				allData[i].productStatus = '1'
            }
            if (allData[i].productStatus == "停售"){
            	allData[i].productStatus = '2'
            }
            if (allData[i].productStatus == '停购'){
            	allData[i].productStatus = '3'
            }
            if (allData[i].productStatus == '淘汰'){
            	allData[i].productStatus = '4'
            }
            if (allData[i].productStatus == '新品'){
            	allData[i].productStatus = '5'
            }

            if (allData[i].specType == '常规'){
            	allData[i].specType = '1'
            }
            if (allData[i].specType == '畅销'){
            	allData[i].specType = '2'
            }
            if (allData[i].specType == '紧俏'){
            	allData[i].specType = '3'
            }
        }
        var type = 1;
        var shopId = $("#shopId").val();
        var year = $("#yearId").val();
        var weekNo = $("#dateSearch").val();
        var itemList = JSON.stringify(allData);
       // console.log('itemList=',itemList);
        layer.confirm('是否确定审批商品？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            layer.load(1);
            $.ajax({
                url: '${contextPath}/ktcount/saveKtTobaccoOrder',
                type: 'post',
                data: {
                	shopId:shopId,
                	type: type,
                	year:year,
                	weekNo:weekNo,
                	itemList: itemList
                },
                success: function (data) {
                	//console.log('审核结果==>',data);
                    layer.closeAll('loading');
                    if (data.success == false){
                        layer.msg("获取出错："+data.message)
                        return
                    }
                    var dataArray = data;
                    layer.msg("提示信息为："+data.message);
                    jQuery(grid_selector).trigger("reloadGrid"); 
                },
                error: function (error) {
                    layer.closeAll('loading')
                    layer.msg("提示："+data.message);
                }
            })
        })
    }
    /* 门店审批功能 */
    var mendian = function () {
    	var ids = $(grid_selector).jqGrid('getGridParam', 'selarrrow');
        var len = ids.length;
        if(len == 0){
            layer.msg("提示：请选择需要审批的订单");
            return
        }
        /* 获取表格输入框中的值  */
        var rowId = $(grid_selector).jqGrid("getGridParam", "selarrrow"); 
        for(var x = 0; x < rowId.length; x++){
        	var specialBrandQuantity = rowId[x] + "_specialBrandQuantity"; 
        	var zoneCheckQuantity = rowId[x] + "_zoneCheckQuantity";  
        	var confirmQuantity = rowId[x] + "_confirmQuantity"; 
        	var remark = rowId[x] + "_remark";
        	var shopRecommendUnitQuantity = rowId[x] + "_shopRecommendUnitQuantity";
        	//console.log('shopRecommendUnitQuantity=',shopRecommendUnitQuantity);
            var specialBrandQuantity= $('#'+specialBrandQuantity).val(); 
            var zoneCheckQuantity= $('#'+zoneCheckQuantity).val();
            var confirmQuantity= $('#'+confirmQuantity).val(); 
            var remark= $('#'+remark).val(); 
            var shopRecommendUnitQuantity= $('#'+shopRecommendUnitQuantity).val(); 
         　		$(grid_selector).jqGrid('setRowData',rowId[x],{
         　			specialBrandQuantity:specialBrandQuantity,
         　			zoneCheckQuantity:zoneCheckQuantity,
          			confirmQuantity:confirmQuantity,
          			remark:remark,
          			shopRecommendUnitQuantity:shopRecommendUnitQuantity
          			},''); 
        }
            
        /* 获取表格所有数据  */
        var selectedIds = $(grid_selector).jqGrid("getGridParam", "selarrrow");     
        var allData = $(grid_selector).getRowData();
        var shopId = $("#shopId").val();
        var delectedData = [];
        for(var i = 0; i< selectedIds.length; i++){
        	delectedData.push(allData[i]);
        	allData[i].batchNo = allData[i].batchNo;
        	allData[i].shopId = shopId;
			for(var x = 0; x <= i; x++){		 
				 allData[i].id = selectedIds[x]; 
        	}
			if(allData[i].seasonType == '平常'){
				allData[i].seasonType = '1'
			}
			if(allData[i].seasonType == '旺季'){
				allData[i].seasonType = '2'
			}
			if(allData[i].seasonType == '中秋'){
				allData[i].seasonType = '3'
			}
			if(allData[i].seasonType == '春节'){
				allData[i].seasonType = '4'
			}
			if (allData[i].productStatus == '正常'){
				allData[i].productStatus = '1'
            }
            if (allData[i].productStatus == "停售"){
            	allData[i].productStatus = '2'
            }
            if (allData[i].productStatus == '停购'){
            	allData[i].productStatus = '3'
            }
            if (allData[i].productStatus == '淘汰'){
            	allData[i].productStatus = '4'
            }
            if (allData[i].productStatus == '新品'){
            	allData[i].productStatus = '5'
            }
            if (allData[i].specType == '常规'){
            	allData[i].specType = '1'
            }
            if (allData[i].specType == '畅销'){
            	allData[i].specType = '2'
            }
            if (allData[i].specType == '紧俏'){
            	allData[i].specType = '3'
            }
        }
        var type = 1;
        var shopId = $("#shopId").val();
        var year = $("#yearId").val();
        var weekNo = $("#dateSearch").val();
        var itemList = JSON.stringify(delectedData);
       // console.log('itemList=',itemList);
        layer.confirm('是否确定审批商品？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            layer.load(1);
            $.ajax({
                url: '${contextPath}/ktcount/saveKtTobaccoOrder',
                type: 'post',
                data: {
                    shopId:shopId,
                	type: type,
                	year:year,
                	weekNo:weekNo,
                	itemList: itemList
                },
                success: function (data) {
                    layer.closeAll('loading');
                    if (data.success == false){
                        layer.msg("获取出错："+data.message)
                        return
                    }
                    var dataArray = data;
                    layer.msg("提示信息为："+data.message);
                    jQuery(grid_selector).trigger("reloadGrid"); 
                },
                error: function (error) {
                    layer.closeAll('loading')
                    layer.msg("提示："+data.message);
                }
            })
        })
    }
	/* 计算  */
	var compute = function(){
		var ids = $(grid_selector).jqGrid('getGridParam', 'selarrrow');
        var len = ids.length;
        if(len == 0){
            layer.msg("提示：请选择所有订单");
            return
        }
        //var allData = $(grid_selector).getRowData();
        var selectedIds = $(grid_selector).jqGrid("getGridParam", "selarrrow");
        for(var i=0;i<selectedIds.length;i++){
        	//这是获得 某一行的数据          
           var gridData= $(grid_selector).jqGrid("getRowData",selectedIds[i]);
        	//console.log("选中行总数据===---》",gridData.productStatus);
         	//行ID和列名字,决定了一个单元格的位置，从而可以取出单元格的值
           /* var strValue=$(grid_selector).jqGrid("getCell",selectedIds[i],"xishu1");
           console.log('strValue',strValue); */
         	//设置单元格的值，需要行id，列名，以及对应列名的值
       
	       	/* 订货状态 */
	       	   if(gridData.xishu1 == '0'){ 
				   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"orderStatus","NO");
			   }else{
				   if(gridData.xishu1 == '2'){
					   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"orderStatus","补货");
				   }
				   if(gridData.xishu1 == '1' && (gridData.unitStock < (gridData.dailySales * (10 + gridData.stockMinDay) * gridData.xishu2 * gridData.xishu3))){
					   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"orderStatus","补货");
				   }else{
					   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"orderStatus","NO");
				   }
			   }	
			   /* 系统建议订货值（包数） */
/* 			   var allData3 = $(grid_selector).getRowData();		   
			   if(allData3[i].orderStatus == 'NO'){
				   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"systemRecommendQuantity",0);
			   }else{
				   if(allData3[i].xishu1 == '2'){
					   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"systemRecommendQuantity",10);
				   }
				   if(allData3[i].xishu1 == '1'){
					   var num = allData3[i].dailySales * (10 + allData3[i].stockMaxDay) * allData3[i].xishu2 * allData3[i].xishu3 - allData3[i].unitStock;
					   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"systemRecommendQuantity",num.toFixed(2));
				   }
			   } */
			   /* 系统建议订货值（条数） */
			   var gridData= $(grid_selector).jqGrid("getRowData",selectedIds[i]);
			   if(gridData.orderStatus == 'NO'){
				   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"systemRecommendUnitQuantity",0);
			   }else{
				   if(gridData.xishu1 == '2'){
					   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"systemRecommendUnitQuantity",10);
				   }
				   if(gridData.xishu1 == '1'){
					   var num = gridData.dailySales * (10 + gridData.stockMaxDay) * gridData.xishu2 * gridData.xishu3 - gridData.unitStock;
					   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"systemRecommendUnitQuantity",num.toFixed(2));
				   }
			   }
/* 			   var res = (allData4[i].systemRecommendQuantity / allData4[i].quantity).toFixed(2)
			   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"systemRecommendUnitQuantity",res); */

			   /* 门店建议订购  */
			   var gridData= $(grid_selector).jqGrid("getRowData",selectedIds[i]);
			   var shopOrder = gridData.systemRecommendUnitQuantity;			   
			   if(shopOrder){
				   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"shopRecommendUnitQuantity",shopOrder);
			   } 
			   /* 区域审核订购量  */
			   var gridData= $(grid_selector).jqGrid("getRowData",selectedIds[i]);
			   var shopRecommendUnitQuantity = gridData.shopRecommendUnitQuantity;			   
			   if(shopRecommendUnitQuantity){
				   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"zoneCheckQuantity",shopRecommendUnitQuantity);
			   } 
			   /* 确认订购  */
			   var gridData= $(grid_selector).jqGrid("getRowData",selectedIds[i]);
			   var zoneCheckQuantity = gridData.zoneCheckQuantity;
			   var setv =  $(grid_selector).jqGrid("setCell",selectedIds[i],"confirmQuantity",zoneCheckQuantity);
    	}        
	}
    /**
     * 搜索店铺订单 
     */
     function searchOrder() {  
    	 var year = $("#yearId").val();
         var weekNo = $("#dateSearch").val();
         var shopId = $("#shopId").val();
         var type = 1;
        $(grid_selector).jqGrid('setGridParam', {
        	url: "${contextPath}/ktcount/getKtTobaccoOrder",
            datatype: 'json',
            postData: {
            	year:year,
            	weekNo:weekNo,
            	shopId:shopId,
            	type:type
            }
        }).trigger("reloadGrid");
    }
    
/*     $("#dateSearch").change(function (){
    	 alert('ppp'+$("#yearId").val()+"年   第 "+$("#dateSearch").val()+"周");
        var year = $("#yearId").val();
        var weekNo = $("#dateSearch").val();
        var shopId = $("#shopId").val();
        var type = 1;
        $(grid_selector).jqGrid('setGridParam', {
        	url: "${contextPath}/ktcount/getKtTobaccoOrder",
            datatype: 'json',
            postData: {
            	year:year,
            	weekNo:weekNo,
            	shopId:shopId,
            	type:type
            }
        }).trigger("reloadGrid");
    }) */
    
    var submitReq = function () {
        var ids = $(grid_selector).jqGrid('getGridParam', 'selarrrow');
        if (ids.length == 0){
            layer.msg("你没有选择添加商品！");
            return;
        }
        var prodList = [];
        for(var i=0;i<ids.length;i++){
            var quantityId = "#quantity_"+ids[i];
            var rowData = $(grid_selector).jqGrid('getRowData', ids[i]);
            var idArray = {};
            idArray.productCode = rowData.productCode;
            idArray.requireShopId = rowData.requireShopId.split('>')[1].split('<')[0];
            var quantity = $(quantityId).val();
            if (quantity == '0'){
                layer.msg("提示："+rowData.productName+"商品没有要货数不能为0！");
                return;
            }
            idArray.quantity = quantity;
            prodList.push(idArray);
        }
        prodList.id = idArray;
        queryModel.prodList = JSON.stringify(prodList);
//        queryModel.id = id;
        $.ajax({
            url: '${contextPath}/ktPurchase/saveShopRequireOrder',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;
                layer.msg("提示："+data.message)
                reload()
            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    /*************  新增商品 **********/


    var reload = function () {
//        $(grid_selector).jqGrid('clearGridData');  //清空表格
        $(grid_selector).jqGrid('setGridParam',{
            url:"${contextPath}/ktProd/getCenterRecommendTightTobaccoByPage",
            datatype:'json',
//                    postData:param,
            page:1
        }).trigger("reloadGrid"); //重新载入
    }
    
</script>

<!-- 复用jqGrid 方法 -->
<script type="text/javascript">

    //选中行启用行编辑
    var EditSelectRow = function(grid_id, id) {
        //原选中行ID
        if (id != null && id != "" && id.length > 0) {
            $(grid_id).jqGrid('saveRow', id);//保存上一行
        }
        //当前选中行
        $(grid_id).val(id);//临时存储当前选中行
//        $(grid_id).jqGrid('editRow', id);
        $(grid_id).jqGrid('editRow', id, {keys: true, focusField: 1});
    }

    function style_edit_form(form) {
        //enable datepicker on "sdate" field and switches for "stock" field
        //form.find('input[name=sdate]').datepicker({format:'yyyy-mm-dd' , autoclose:true})

        //form.find('input[name=stock]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
        //don't wrap inside a label element, the checkbox value won't be submitted (POST'ed)
        //.addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');


        //update buttons classes
        var buttons = form.next().find('.EditButton .fm-button');
        buttons.addClass('btn btn-sm').find('[class*="-icon"]').hide();//ui-icon, s-icon
        buttons.eq(0).addClass('btn-primary').prepend('<i class="ace-icon fa fa-check"></i>');
        buttons.eq(1).prepend('<i class="ace-icon fa fa-times"></i>')

        buttons = form.next().find('.navButton a');
        buttons.find('.ui-icon').hide();
        buttons.eq(0).append('<i class="ace-icon fa fa-chevron-left"></i>');
        buttons.eq(1).append('<i class="ace-icon fa fa-chevron-right"></i>');
    }

    function style_delete_form(form) {
        var buttons = form.next().find('.EditButton .fm-button');
        buttons.addClass('btn btn-sm btn-white btn-round').find('[class*="-icon"]').hide();//ui-icon, s-icon
        buttons.eq(0).addClass('btn-danger').prepend('<i class="ace-icon fa fa-trash-o"></i>');
        buttons.eq(1).addClass('btn-default').prepend('<i class="ace-icon fa fa-times"></i>')
    }

    function style_search_filters(form) {
        form.find('.delete-rule').val('X');
        form.find('.add-rule').addClass('btn btn-xs btn-primary');
        form.find('.add-group').addClass('btn btn-xs btn-success');
        form.find('.delete-group').addClass('btn btn-xs btn-danger');
    }

    function style_search_form(form) {
        var dialog = form.closest('.ui-jqdialog');
        var buttons = dialog.find('.EditTable')
        buttons.find('.EditButton a[id*="_reset"]').addClass('btn btn-sm btn-info').find('.ui-icon').attr('class', 'ace-icon fa fa-retweet');
        buttons.find('.EditButton a[id*="_query"]').addClass('btn btn-sm btn-inverse').find('.ui-icon').attr('class', 'ace-icon fa fa-comment-o');
        buttons.find('.EditButton a[id*="_search"]').addClass('btn btn-sm btn-purple').find('.ui-icon').attr('class', 'ace-icon fa fa-search');
    }

    function beforeDeleteCallback(e) {
        var form = $(e[0]);
        if (form.data('styled')) return false;

        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
        style_delete_form(form);
        form.data('styled', true);
    }

    function beforeEditCallback(e) {
        var form = $(e[0]);
        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
        style_edit_form(form);
    }

    function styleCheckbox(table) {


    }

    function updateActionIcons(table) {

    }

    //replace icons with FontAwesome icons like above
    function updatePagerIcons(table) {
        var replacement =
            {
                'ui-icon-seek-first': 'ace-icon fa fa-angle-double-left bigger-140',
                'ui-icon-seek-prev': 'ace-icon fa fa-angle-left bigger-140',
                'ui-icon-seek-next': 'ace-icon fa fa-angle-right bigger-140',
                'ui-icon-seek-end': 'ace-icon fa fa-angle-double-right bigger-140'
            };
        $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function () {
            var icon = $(this);
            var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

            if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]);
        })
    }

    function enableTooltips(table) {
        $('.navtable .ui-pg-button').tooltip({container: 'body'});
        $(table).find('.ui-pg-div').tooltip({container: 'body'});
    }


    var reload = function () {
//        $(grid_promotion_selector).jqGrid('clearGridData');  //清空表格
        $(grid_selector).jqGrid('setGridParam',{
            url:"${contextPath}/ktProd/getCenterRecommendTightTobaccoByPage",
            datatype:'json',
//                    postData:param,
            page:1
        }).trigger("reloadGrid"); //重新载入
    }
    
</script>

<script type="text/javascript" src="${contextPath}/static/ace/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="${contextPath}/static/ace/components/jqGrid/js/jquery.jqGrid.js"></script>
<script type="text/javascript" src="${contextPath}/static/ace/components/jqGrid/js/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="${contextPath}/static/layer/layer.js"></script>
<script type="text/javascript" src="${contextPath}/static/ztree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="${contextPath}/static/ztree/js/jquery.ztree.excheck-3.5.js"></script>
<!-- jqGrid加载数据 -->
<script type="text/javascript">
    var grid_data = '${id}';
    var scripts = [null, "${contextPath}/static/ace/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js", "${contextPath}/static/ace/components/jqGrid/js/jquery.jqGrid.js", "${contextPath}/static/ace/components/jqGrid/js/i18n/grid.locale-cn.js", "${contextPath}/static/layer/layer.js","${contextPath}/static/ztree/js/jquery.ztree.core-3.5.js", "${contextPath}/static/ztree/js/jquery.ztree.excheck-3.5.js", null]
    $('.page-content-area').ace_ajax('loadScripts', scripts, function () {

        jQuery(function ($) {

            var parent_column = $(grid_selector).closest('[class*="col-"]');
            //resize to fit page size
            $(window).on('resize.jqGrid', function () {
                $(grid_selector).jqGrid('setGridWidth', parent_column.width());
            })

            //resize on sidebar collapse/expand
            $(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
                if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
                    //setTimeout is for webkit only to give time for DOM changes and then redraw!!!
                    setTimeout(function () {
                        $(grid_selector).jqGrid('setGridWidth', parent_column.width());
                    }, 20);
                }
            })
            /* 选择店铺  */
            /* $('#shopId').change(function () {
                var shopId = $("#shopId").val();
                console.log('shopId==',shopId);
                $(grid_selector).jqGrid('setGridParam',{
                    url: "${contextPath}/ktcount/getKtTobaccoOrder",
                    datatype: 'json',
                    postData: {shopId:shopId},
                }).trigger("reloadGrid"); //重新载入
            }) */
            var year = $("#yearId").val();
            var weekNo = $("#dateSearch").val();
            var shopId = $("#shopId").val();
            var type = 1;
            jQuery(grid_selector).jqGrid({
                subGrid: false,
                url : '${contextPath}/ktcount/getKtTobaccoOrder',
                postData: {
                	year:year,
                   	weekNo:weekNo,
                   	shopId:shopId,
                   	type:type
                },
                datatype: "json",
                mtype: 'POST',
                height: 500,
                colNames: [ '条码', '品名', '规格', 'unit', '商品<br/>状态', '系数', '品规<br/>类别', '系数', '季节<br/>类别', '系数', '下限', '上限'
                	, '月销量<br/>(条)', '日均销量<br/>天/条', '库存<br/>条数', '订货<br/>状态', '建议订购<br/>条数', '门店<br/>确认', '区域<br/>确认'
                	, '确认<br/>订购(条)', '实际<br/>订购(条)', '备注', 'batchNo'],
                colModel: [
                	/*  {name: 'number', index: 'number', align: 'center'}, */
                     {name: 'productCode', index: 'productCode', align: 'center', width: 400},
                     {name: 'productName', index: 'productName', align: 'center', width: 500},
                     {name: 'unit', index: 'unit', align: 'center', width: 500},
                     {
                    	 name: 'quantity', 
                    	 index: 'quantity', 
                    	 align: 'center',
                    	 width: 300,
                    	 hidden:true,
                    	 formatter: function(v, x, r){
                    		 if (r.quantity == "" || r.quantity == null){
                    			 return parseInt(1);
                             }else{
                            	 return r.quantity;
                             }
                    	 }
                     },
                     {
                    	 name: 'productStatus', 
                    	 index: 'productStatus', 
                    	 align: 'center', 
                    	 width: 400,            	
                          formatter: function (v, x, r) {
                             if (r.productStatus == '1' || r.productStatus == null || r.productStatus == ""){
                                 return '正常'
                             }
                             if (r.productStatus == "2"){
                                 return '停售'
                             }
                             if (r.productStatus == '3'){
                                 return '停购'
                             }
                             if (r.productStatus == '4'){
                                 return '淘汰'
                             }
                             if (r.productStatus == '5'){
                                 return '新品'
                             }
                             return ''
                         },   
                     },
                     {
                    	 name: 'xishu1', 
                    	 index: 'xishu1', 
                    	 align: 'center',
                    	 hidden:true,
                    	 width: 300,
                    	 formatter:function(v, x, r){
                    		 if(r.productStatus == '1' || r.productStatus == null || r.productStatus == ""){
                    			 return parseFloat(1)
                    		 }else if(r.productStatus == "2" || r.productStatus == '3' || r.productStatus == '4'){
                    			 return parseFloat(0)
                    		 }else if(r.productStatus == '5'){
                    			 return parseFloat(2)
                    		 }
                    	 }
                    },
                     {
                    	 name: 'specType', 
                    	 index: 'specType', 
                    	 align: 'center',
                    	 width: 400, 
                    	 formatter: function (v, x, r) {
                             if (r.specType == '1' || r.specType == null || r.specType == ""){
                                 return '常规'
                             }
                             if (r.specType == '2'){
                                 return '畅销'
                             }
                             if (r.specType == '3'){
                                 return '紧俏'
                             }
                             return ''
                         }
                     },
                     {
                    	 name: 'xishu2', 
                    	 index: 'xishu2', 
                    	 hidden:true,
                    	 align: 'center',
                    	 width: 300,
                    	 formatter:function(v, x, r){
                    		 if(r.specType == '1' || r.specType == null || r.specType == ""){
                    			 return parseFloat(1.0)
                    		 }else if(r.specType == '2'){
                    			 return parseFloat(1.5)
                    		 }else if(r.specType == '3'){
                    			 return parseFloat(2.0)
                    		 }
                    	 }
                    },
                     {
                    	 name: 'seasonType', 
                    	 index: 'seasonType', 
                    	 align: 'center', 
                    	 width: 400, 
                    	 formatter: function (v, x, r) {
                             if (r.seasonType == '1' || r.seasonType == null || r.seasonType == ""){
                                 return '平常'
                             }
                             if (r.seasonType == "2"){
                                 return '旺季'
                             }
                             if (r.seasonType == '3'){
                                 return '中秋'
                             }
                             if (r.seasonType == '4'){
                                 return '春节'
                             }
                             return ''
                         },
                     },
                     {
                    	 name: 'xishu3', 
                    	 index: 'xishu3', 
                    	 hidden:true,
                    	 align: 'center',
                    	 width: 300,
                    	 formatter: function (v, x, r) {
                             if (r.seasonType == '1' || r.seasonType == null || r.seasonType == ""){
                                 return parseFloat(1.0)
                             }
                             if (r.seasonType == "2"){
                                 return parseFloat(1.3)
                             }
                             if (r.seasonType == '3'){
                                 return parseFloat(1.5)
                             }
                             if (r.seasonType == '4'){
                                 return parseFloat(2.0)
                             }
                             return ''
                         },
                    },
                     {
                    	name: 'stockMinDay', 
                    	index: 'stockMinDay', 
                    	align: 'center',
                    	width: 400,
                    	formatter: function (v, x, r){
	                   		 if(r.stockMinDay == undefined || r.stockMinDay == null || r.stockMinDay == ""){
	                   			return parseInt(0);
	                   		 }else{
                    			 return parseInt(r.stockMinDay);
                    		 }		
                   		 }
                   	 },
                     {
                    	 name: 'stockMaxDay', 
                    	 index: 'stockMaxDay', 
                    	 align: 'center',
                    	 width: 400,
                    	 formatter: function (v, x, r){
                    		 if(r.stockMaxDay == undefined || r.stockMaxDay == null || r.stockMaxDay == ""){
                    			 return parseInt(0);
                    		 }else{
                    			 return parseInt(r.stockMaxDay);
                    		 }	 
                    	}
                    },
                     {
                    	name: 'monthSales', 
                    	index: 'monthSales', 
                    	align: 'center',
                    	width:400,
                    	formatter: function (v, x, r){
                    		if( r.monthSales == null || r.monthSales == ""){
                    			return parseInt(0);
                    		}else{
                    			return parseFloat(r.monthSales);
                    		}
                    	}
                    },
                     {
                    	 name: 'dailySales', 
                    	 index: 'dailySales', 
                    	 align: 'center',
                    	 width:400,
                    	 formatter: function (v, x, r){
                    		if( r.dailySales == null || r.dailySales == ""){
                     			return parseInt(0);
                     		}else{
                     			return parseFloat(r.dailySales);
                     		}
                    	 }
                     },
/*                      {
                    	 name: 'stock', 
                    	 index: 'stock', 
                    	 align: 'center',
                    	 width:400,
                    	 formatter: function (v, x, r){
                    		 console.log('data==',r);
                    		 if(r.stock ==  null || r.stock == ""){
                    			 return parseInt(0);
                    		 }else{
                    			 return parseFloat(r.stock);
                    		 }                    		 
                    	 }
                    }, */
                     {
                    	 name: 'unitStock', 
                    	 index: 'unitStock', 
                    	 align: 'center',
                    	 width:400,
                    	 formatter: function (v, x, r){
                    		 if(r.unitStock ==  null || r.unitStock == ""){
                    			 return parseInt(0);
                    		 }else{
                    			 return parseFloat(r.unitStock);
                    		 }                    		 
                    	 }
                    },
                     {
                    	 name: 'orderStatus', 
                    	 index: 'orderStatus', 
                    	 align: 'center',
                    	 width:400,
                    },
/*                      {
                    	name: 'systemRecommendQuantity', 
                    	index: 'systemRecommendQuantity', 
                    	align: 'center',
                    	width:500,
                    }, */
                     {
                    	name: 'systemRecommendUnitQuantity', 
                    	index: 'systemRecommendUnitQuantity', 
                    	align: 'center',
                    	width:500,
                    },
                     {
                     	name: 'shopRecommendUnitQuantity', 
                     	index: 'shopRecommendUnitQuantity', 
                     	editable: true,  
                     	align: 'center',
                     	width: 500,
                     	editrules:{number:true},
                     	/* formatter:function(v, x, r){
                     		var shopRecommendUnitQuantity = r.shopRecommendUnitQuantity;
                     		if(shopRecommendUnitQuantity == null){
                     			return shopRecommendUnitQuantity = 0;
                     		}
                     	} */ 
                     },
                     {
                    	 name: 'zoneCheckQuantity', 
                    	 editable: true, 
                    	 index: 'zoneCheckQuantity', 
                    	 align: 'center',
                    	 editrules:{number:true},
                    	 width: 500,
                    	 /* formatter:function(v, x, r){
                      		var zoneCheckQuantity = r.zoneCheckQuantity;
                      		if(zoneCheckQuantity == null){
                      			return zoneCheckQuantity = 0;
                      		}
                      	} */
                    	 
                     },
                     {
                    	 name: 'confirmQuantity', 
                    	 index: 'confirmQuantity', 
                    	 align: 'center',
                    	 width: 500,
                      },
                     {
                    	  name: 'actualQuantity', 
                    	  index: 'actualQuantity', 
                    	  align: 'center',
                    	  width: 500,
                    	  formatter: function (v, x, r){
                     		 if(r.actualQuantity ==  null || r.actualQuantity == ""){
                     			 return parseInt(0);
                     		 }else{
                     			 return parseFloat(r.actualQuantity);
                     		 }                    		 
                     	 }
                     },
                     {name: 'remark', editable: true, index: 'remark', align: 'center',width: 350,},
                     {name: 'batchNo', hidden: true, index: 'batchNo', align: 'center'},
                ],
                autowidth: true,  //宽度自适应
                viewrecords: true,                
                 rowNum: 1000000,
                 multiselect: true,
                 rownumbers: true,  
                 /*rowList: [10, 20, 30], */
                /* pager: pager_selector, */
               /*  altRows: true, */
                /* toppager: true, */
                multiboxonly: false,
                forceFit : true,
                cellEdit: true,
                cellsubmit: 'clientArray',
                loadonce: true, //一次加载全部数据到客户端，由客户端进行排序。
                sortable: true,
                sortname: 'zykj', //设置默认的排序列
                sortorder: 'asc',
               
                loadComplete: function () {
                    var table = this;
                    setTimeout(function () {
                        styleCheckbox(table);
                        updateActionIcons(table);
                        updatePagerIcons(table);
                        enableTooltips(table);
                    }, 0);
                },
                /* editurl: "${contextPath}/ktProd/getCenterRecommendTightTobaccoByPage", */
                caption: "卷烟订购表",
                jsonReader: {
                    root: "data",
                    page: "currentPage",
                    total: "pageCount",
                    records: "recordCount",
                },
                //单击
                onSelectRow : function(id) {

                },
                ondblClickRow: function (id) {
                    EditSelectRow(grid_selector ,id);
                    var rowData = $(grid_selector).jqGrid('getRowData', id);
                    var quantityId = '#'+id+'_quantity1';
                    rowData.quantity1 = $(quantityId).val()
                },
				/* 数据联动   */
                afterSaveCell : function(rowid,name,val,iRow,iCol) {               	
                    if(name == 'shopRecommendUnitQuantity') { 
                      jQuery(grid_selector).jqGrid('setRowData',rowid,{zoneCheckQuantity:parseFloat(val)});
                      jQuery(grid_selector).jqGrid('setRowData',rowid,{confirmQuantity:parseFloat(val)});
                    }
                    
                    if(name == 'zoneCheckQuantity') { 
                       /*  jQuery(grid_selector).jqGrid('setRowData',rowid,{zoneCheckQuantity:parseFloat(val)}); */
                        jQuery(grid_selector).jqGrid('setRowData',rowid,{confirmQuantity:parseFloat(val)});
                    }
                }

                <%--editurl : '${contextPath}/ktProd/getCenterRecommendTightTobaccoByPage',--%>
                <%--caption : "Using events example"--%>
            });
            jQuery(grid_selector).jqGrid('navGrid', grid_selector, {
                edit : false,
                add : false,
                del : false
                //autowidth: true,
            });
      	   /* jQuery(grid_selector).jqGrid('setGroupHeaders', {
      	    useColSpanStyle: true, 
      	    groupHeaders:[
      	     {startColumnName: 'productCode', numberOfColumns: 3, titleText: '产品信息'}, 
      	     {startColumnName: 'productStatus', numberOfColumns: 2, titleText: '商品状态系数'},
      	     {startColumnName: 'specType', numberOfColumns: 2, titleText: '品规参数'},
      	   	 {startColumnName: 'seasonType', numberOfColumns: 2, titleText: '季节参数'},
      	     {startColumnName: 'stockMinDay', numberOfColumns: 2, titleText: '安全库存参数'},
      	   	 {startColumnName: 'monthSales', numberOfColumns: 2, titleText: '销量参数'},
      	     {startColumnName: 'stock', numberOfColumns: 2, titleText: '库存值'},
      	     {startColumnName: 'systemRecommendQuantity', numberOfColumns: 2, titleText: '系统建议订货值'},
      	    ]  
      	  }); */ 
      	  	/* 权限判断  */
             var arr = jQuery("#approval");
             if(arr.length == 0){            	
            	var colModel=$(grid_selector).jqGrid('getGridParam','colModel');
             	colModel[20].editable = false;
             	jQuery(grid_selector).trigger("reloadGrid");           
             }else{
            	var colModel=$(grid_selector).jqGrid('getGridParam','colModel');
              	colModel[19].editable = false;
              	jQuery(grid_selector).trigger("reloadGrid");
             }
            $(window).triggerHandler('resize.jqGrid');
        });
    });
</script>

<!-- 自动补全 -->
<script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="${contextPath}/static/util/my-autocomplete-section.js"></script>


<!-- 商品下拉菜单 -->
<script type="text/javascript">
    /**
     * 下啦联动数据绑定 开始代码
     * @type {{parentId: string}}
     */
    $('#isExpInput').change(function () {
        app.yanType2 = []
        app.yanType3 = []
        app.yanType4 = []
        $("#commodityScreen").addClass("hide");
        queryModel.parentId = $("#isExpInput option:selected").val();
        querySubProdType2()
    });

    $('#isAuthInput').change(function () {
        app.yanType3 = []
        app.yanType4 = []
        $("#commodityScreen").addClass("hide");
        queryModel.parentId = $("#isAuthInput option:selected").val();
        querySubProdType3()
    });

    $('#isAuthInput1').change(function () {
        app.yanType4 = []
        $("#commodityScreen").addClass("hide");
        queryModel.parentId = $("#isAuthInput1 option:selected").val();
        querySubProdType4()
    });

    $('#isAuthInput2').change(function () {
        app.yanType5 = []
        $("#commodityScreen").addClass("hide");
        queryModel.parentId = "";
        queryModel.typeId = $("#isAuthInput2 option:selected").val();
        querySubProdType5()
    });

    var querySubProdType1 = function () {
        queryModel.parentId = '0';
        getSubProdType1(queryModel)
    }
    var querySubProdType2 = function () {
        getSubProdType2(queryModel)
    }
    var querySubProdType3 = function () {
        getSubProdType3(queryModel)
    }
    var querySubProdType4 = function () {
        getSubProdType4(queryModel)
    }
    var querySubProdType5 = function () {
        getSubProdType5(queryModel)
    }


    var getSubProdType1 = function (queryModel) {
//        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktProd/getSubProdType',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;
                app.yanType1 = dataArray;
            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    var getSubProdType2 = function (queryModel) {
        $.ajax({
            url: '${contextPath}/ktProd/getSubProdType',
            type: 'post',
            data: queryModel,
            success: function (data) {
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;
                app.yanType2 = dataArray;

            },
            error: function (error) {
            }
        })
    }

    var getSubProdType3 = function (queryModel) {
//        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktProd/getSubProdType',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;
                app.yanType3 = dataArray;

            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    var getSubProdType4 = function (queryModel) {
//        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktProd/getSubProdType',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;
                app.yanType4 = dataArray;

            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    var getSubProdType5 = function (queryModel) {
//        layer.load(1)
        $.ajax({
            url: '${contextPath}/ktProd/getProdProperty',
            type: 'post',
            data: queryModel,
            success: function (data) {
//                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data;
                app.yanType5 = dataArray;

            },
            error: function (error) {
//                layer.closeAll('loading')
            }
        })
    }

    querySubProdType1(queryModel);

    /**
     * 下啦联动数据绑定 结束代码
     */
</script>

<!-- 数型插件 -->
<script type="text/javascript">

</script>

